package com.weipai.springboot.base.interceptor;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.solr.core.SolrTemplate;

/**
 * @author songmengqiang
 * @create 2018-09-06 10:06
 **/
@Configuration
public class SolrConfig {

    @Value("${solr.url}")
    private String SOLR_SERVER_URL;


    @Bean
    public SolrClient solrClient() {
        HttpSolrClient solrClient = new HttpSolrClient.Builder(SOLR_SERVER_URL)
                .build();
        solrClient.setConnectionTimeout(10000);
        solrClient.setSoTimeout(60000);
        return solrClient;
    }

    @Bean
    public SolrTemplate solrTemplate(SolrClient client){
        return new SolrTemplate(client);
    }
}
